<template>
  <div class="home">
    <div :class="['header',is_no_scroll?'header_relative':'']" :id="is_no_scroll?'':'header'">
      <div class="header_center_box">
        <img src="@/assets/img/logo.png" class="logo" alt @click="homeIndex" />
        <div class="nav">
          <div class="nav_item" @click="navTo('/home/server')">产品与服务</div>

          <el-popover placement="top-start" trigger="hover">
            <div class="popover_item">
              <a href="https://www.cec-smt.com/" rel="noopener noreferrer" target="_blank">中电SMT行业平台</a>
            </div>
            <div class="popover_item">
              <a
                href="http://175.6.101.244:10090/login"
                rel="noopener noreferrer"
                target="_blank"
              >中电数字零售云平台</a>
            </div>
            <div class="nav_item" slot="reference" @click="navTo('/home/industry')">
              <span>行业子平台</span>
            </div>
          </el-popover>
          <el-popover placement="top-start" trigger="hover">
            <div class="popover_item">
              <a
                href="http://www.cs-icloud.com/home/index"
                rel="noopener noreferrer"
                target="_blank"
              >长沙工业云平台</a>
            </div>
            <div class="popover_item">
              <a
                href="http://www.cec-fjii.com.cn/home/index"
                rel="noopener noreferrer"
                target="_blank"
              >中电福建云</a>
            </div>
            <div class="popover_item">
              <a href="https://cecicloud.com/f" rel="noopener noreferrer" target="_blank">江宁产业云</a>
            </div>
            <div class="nav_item" slot="reference" @click="navTo('/home/area')">
              <span>区域子平台</span>
            </div>
          </el-popover>
          <div class="nav_item">工业应用</div>
          <div class="nav_item" @click="navTo('/home/resolve')">解决方案</div>

          <div class="nav_item" @click="navTo('/home/about')">关于我们</div>
        </div>
        <div class="nav_right">
          <!-- <img src="@/assets/img/kf.png" alt class="contact" /> -->
          <!-- <span class="phone">400-885-6022</span> -->
          <div class="cor" @click="navTo('/home/advisoryCooperation')">咨询/合作</div>
          <div class="cor" style="margin-left:10px" @click="gotoControl">控制台</div>
          <div class="login" @click="gotoLogin">登 录</div>
          <div class="register">注 册</div>
        </div>
      </div>
    </div>

    <!-- 主视图 -->
    <div class="main">
      <router-view />
    </div>
    <!-- 官网页脚 -->
    <footer class="footer">
      <Footer />
    </footer>
  </div>
</template>


<script>
// @ is an alias to /src
import Footer from "@/components/HomeCmp/Footer";

//非滚动头部的页面列表
const noScrollHeaderList = ["/home/appDetails"];

export default {
  name: "home",
  components: {
    Footer
  },

  watch: {
    $route() {
      this.checkIsNoScroll();
    }
  },
  data() {
    return {
      is_no_scroll: false
    };
  },
  mounted() {
    document.title = "中电云网";
    this.checkIsNoScroll();
    window.addEventListener("scroll", this.headerScroll.bind(this));
  },
  beforeDestroy() {
    window.removeEventListener("scroll", this.headerScroll.bind(this));
  },

  methods: {
    clickme() {
      console.log(11);
    },
    checkIsNoScroll() {
      const fullPath = this.$route.fullPath;
      if (noScrollHeaderList.includes(fullPath)) {
        this.is_no_scroll = true;
      } else {
        this.is_no_scroll = false;
      }
    },
    headerScroll() {
      let header = document.querySelector("#header");
      let scrollTop =
        document.body.scrollTop || document.documentElement.scrollTop;
      if (scrollTop < 20) {
        header && (header.style.background = "transparent");
      } else {
        header && (header.style.background = "#050B21");
      }
    },
    homeIndex() {
      this.$router.push({ path: "/home/index" });
    },
    gotoControl() {
      this.$router.push({ path: "/cms/index" });
    },
    gotoLogin() {
      this.$router.push({ path: "/login" });
    },
    navTo(path) {
      this.$router.push({ path });
    }
  }
};
</script>

<style lang="less" scoped>
a {
  color: #606266;
  text-decoration: none;
}
a:hover {
  color: #0068f7;
}
/deep/.nav {
  font-size: 14px;
  width: 800px;
  display: flex;
  height: 100%;
  .nav_item {
    padding: 0 20px;
    color: #fff;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    &:hover {
      color: #3ae;
    }
  }
}
.nav_right {
  display: flex;
  margin-left: auto;
  color: #fff;
  height: 100%;
  align-items: center;
  .contact {
    width: 30px;
    height: 30px;
    // background-color: #fff;
    margin-right: 20px;
  }
  .phone {
    font-size: 20px;
    margin-right: 20px;
    transform: translateY(2px);
  }
  .cor {
    font-size: 14px;
    padding: 6px 10px;
    border: 1px solid #f5f5f5;
    border-radius: 20px;
    &:hover {
      color: rgb(5, 10, 70);
      background-color: #fff;
      cursor: pointer;
    }
  }
  .login {
    font-size: 14px;
    padding: 6px 20px;
    border: 1px solid #f5f5f5;
    border-radius: 20px;
    margin-right: 3px;
    color: #333;
    margin-left: 10px;
    background-color: #fff;
    cursor: pointer;
    &:hover {
      color: #fff;
      background-color: #0b1e46;
    }
  }
  .register {
    font-size: 14px;
    padding: 6px 10px;
    // border: 1px solid #f5f5f5;
    border-radius: 20px;
    color: #fff !important;
    margin-right: 10px;
    color: #333;
    // background-color: #fff;
    cursor: pointer;
    &:hover {
      color: rgb(19, 168, 255) !important;
      // background-color: #0b1e46;
    }
  }
}

.popover_item {
  padding: 6px 10px;
  box-sizing: border-box;
  cursor: pointer;
}
html,
body,
.home {
  height: 100%;
}

.main {
  min-height: 100%;
  /* equal to footer height */
  margin-bottom: -440px;
}

.main:after {
  content: "";
  display: block;
}

.footer,
.main:after {
  height: 440px;
}

.footer {
  background: rgb(10, 22, 48);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.content {
  width: 600px;
  height: 600px;
  border: 1px solid #ccc;
}

.header {
  // border-bottom: 1px solid #f5f5f5;
  box-shadow: 0 0 1px rgba(255, 255, 255, 0.5);
  box-sizing: border-box;
  transition: all 0.4s;
  position: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  left: 0;
  top: 0;
  width: 100%;
  height: 61px;
  z-index: 999;
  .header_center_box {
    min-width: 1400px;
    width: 100%;
    height: 100%;
    display: flex;
  }
  .logo {
    width: 280px;
    height: 100%;
    // background-color: #f5f5f5;
    padding: 0 20px;
  }
}
.header_relative{
  background: #050B21 !important;
  position: relative;
}
* {
  margin: 0;
}
</style>